package com.haven123.cloudapp.rabbitmq.Config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Exchange;
import org.springframework.amqp.core.Queue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class BindingConfig {
    @Autowired private Queue queue1;
    @Autowired private Queue queue2;
    @Autowired private Queue queue3;
    @Autowired private Queue queue4;
    @Autowired private Queue queue5;
    @Autowired private Exchange directExhange;
    @Autowired private Exchange fanoutExhange;
    @Autowired private Exchange topicExhange;
    @Autowired private Exchange directExhangedlx;
    public static final String routingKey_one="one";
    public static final String routingKey_two="two";
    public static final String routingKey_three="three";
    public static final String routingKey_four="1.four.tipic.2";
    public static final String routingKey_five="five";
    public static final String routingKey_six="six";
    public static final String routingKey_seven="seven";
    public static final String routingKey_eight="eight";
    public static final String routingKey_nine="nine";
    public static final String routingKey_ten="ten";

    @Bean
    public Binding bindingone(){
        return BindingBuilder.bind(queue1).to(directExhange).with(routingKey_one).noargs();
    }
    @Bean
    public Binding bindingtwo(){
        return BindingBuilder.bind(queue1).to(directExhange).with(routingKey_two).noargs();
    }
    @Bean
    public Binding bindingthree(){
        return BindingBuilder.bind(queue1).to(fanoutExhange).with(routingKey_three).noargs();
    }
    @Bean
    public Binding bindingfoure(){
        return BindingBuilder.bind(queue2).to(fanoutExhange).with(routingKey_three).noargs();
    }
    @Bean
    public Binding bindingfive(){
        return BindingBuilder.bind(queue3).to(fanoutExhange).with(routingKey_three).noargs();
    }
    @Bean
    public Binding bindingsix(){
        return BindingBuilder.bind(queue1).to(topicExhange).with(routingKey_four).noargs();
    }
    @Bean
    public Binding bindingseven(){
        return BindingBuilder.bind(queue4).to(directExhange).with(routingKey_seven).noargs();
    }
//    这是一个普通的交换器但是被其他队列指定为死信队列。
    @Bean
    public Binding bindingeight(){
        return BindingBuilder.bind(queue5).to(directExhangedlx).with(routingKey_eight).noargs();
    }


}
